home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Original Shareware 1.1
/
The Original Shareware (WeMake CDs)(Volume 1.1)(CDs, Inc)(1993).iso
/
6
/
ctone.zip
/
PIANO.C
next >
Wrap
Text File
|
1984-12-04
|
1KB
|
55 lines
/* FILENAME: piano.c
*/
#include <stdio.h> /* use unbuffered i/o */
#include <ctype.h>
#define C 262 /* define frequencies */
#define D 294
#define E 330
#define F 349
#define G 392
#define A 440
#define B 494
#define C2 524
main ()
{
int key, freq, tempo, time;
puts ("Please enter the basic tempo: 10 = 1 second.");
scanf ("%d", &tempo);
printf ("%d\n\r", tempo); /* echo input */
puts ("Thank you. Use the key row a-k to play notes. The\n\r");
puts ("shift key doubles the duration. A ! halts the show.");
while ( (key = getchar()) != '!')
{
time = isupper (key) ? 2 * tempo : tempo;
key = tolower (key);
switch (key)
{
case 'a': tone ( C, time);
break;
case 's': tone ( D, time);
break;
case 'd': tone ( E, time);
break;
case 'f': tone ( F, time);
break;
case 'g': tone ( G, time);
break;
case 'h': tone ( A, time);
break;
case 'j': tone ( B, time);
break;
case 'k': tone ( C2, time);
break;
default: break;
}
}
puts ("Bye bye!\n\r");
}